﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace scmsByAspdNet.cotro.admin {
  /// <summary>
  /// updateNews 的摘要说明
  /// </summary>
  public class updateNews : IHttpHandler {

    public void ProcessRequest(HttpContext context) {
      context.Response.ContentType = "text/plain";
      string id = context.Request["id"];
      string is_open = context.Request["is_open"];

      //更新操作
      SqlConnection conn = new SqlConnection("Data Source=106.54.69.143;database=scms;uid=sa;pwd=Aspdotnet666");
      conn.Open();

      SqlCommand sql_u = new SqlCommand($"update sc_news set is_open={is_open} where id={id}", conn);
      int res = sql_u.ExecuteNonQuery();
      conn.Close();
      //返回数据
      context.Response.StatusCode = 200;
      context.Response.Write($"{{\"line\":{res}}}");
    }

    public bool IsReusable {
      get {
        return false;
      }
    }
  }
}